<% page_title "Kubernetes Roles" %>

<%= render 'projects/header', project: @project, tab: 'kubernetes' %>

<section class="tabs kubernetes-section clearfix">
  <%= render 'samson_kubernetes/role_navigation' %>

  <% if @roles.none? %>
    <%= render 'seed' %>
  <% else %>
    <div class="table table-hover table-condensed">
      <table class="table">
        <tr>
          <th>Name</th>
          <th>Config</th>
          <th>Service Name</th>
          <th>Resource</th>
          <th></th>
        </tr>

        <% @roles.each do |role| %>
          <tr>
            <td><%= link_to role.name, [@project, role] %></td>
            <td><%= role.config_file %></td>
            <td><%= role.service_name %></td>
            <td><%= role.resource_name %></td>
            <td>
              <%= link_to 'Edit', [@project, role] if current_user.admin_for?(role.project) %>
            </td>
          </tr>
        <% end %>
      </table>
    </div>
  <% end %>

  <% if current_user.admin_for?(@project) %>
    <div class="admin-actions">
      <div class="pull-right">
        <%= link_to "Verify config", new_kubernetes_role_verification_path, class: "btn btn-default" %>
        <%= link_to "New", new_project_kubernetes_role_path(@project), class: "btn btn-default" %>
      </div>
    </div>
  <% end %>
</section>
